<?php
require 'header.php';
require 'includes/db.php';
?>
<html>
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
	
	<?php
	if(isset($_POST['aboutus'])){
	$name= $_POST['page'];
    $p_image = $_FILES['image']['name'];
    $p_image = date('ymdHis') . '_' . uniqid() . '_' . $p_image;
    $fileInfoArray = pathinfo($p_image);
    $src = $_FILES['image']['tmp_name'];
    $dest = "../images/$p_image";
    $isMoved = @move_uploaded_file($src, $dest);
	if($isMoved== true){
    $_POST['image'] = $p_image;
	$sql="update pages set image='$p_image' where name='$name'";
    $result=mysql_query($sql)or die(mysql_error());
	
	echo success("Image Changed Successfully");
	}else{
		echo error("File Not Upload");
		}
	}
	if(isset($_POST['why_cyberlinks'])){
	$name= $_POST['page'];
    $p_image = $_FILES['image']['name'];
    $p_image = date('ymdHis') . '_' . uniqid() . '_' . $p_image;
    $fileInfoArray = pathinfo($p_image);
    $src = $_FILES['image']['tmp_name'];
    $dest = "../images/$p_image";
    $isMoved = @move_uploaded_file($src, $dest);
	if($isMoved== true){
    $_POST['image'] = $p_image;
	$sql="update pages set image='$p_image' where name='$name'";
    $result=mysql_query($sql)or die(mysql_error());
	
	echo success("Image Changed Successfully");
	}else{
		echo error("File Not Upload");
		}
	}
	if(isset($_POST['android_development'])){
	$name= $_POST['page'];
    $p_image = $_FILES['image']['name'];
    $p_image = date('ymdHis') . '_' . uniqid() . '_' . $p_image;
    $fileInfoArray = pathinfo($p_image);
    $src = $_FILES['image']['tmp_name'];
    $dest = "../images/$p_image";
    $isMoved = @move_uploaded_file($src, $dest);
	if($isMoved== true){
    $_POST['image'] = $p_image;
	$sql="update pages set image='$p_image' where name='$name'";
    $result=mysql_query($sql)or die(mysql_error());
	
	echo success("Image Changed Successfully");
	}else{
		echo error("File Not Upload");
		}
	}
	if(isset($_POST['iphone_development'])){
	$name= $_POST['page'];
    $p_image = $_FILES['image']['name'];
    $p_image = date('ymdHis') . '_' . uniqid() . '_' . $p_image;
    $fileInfoArray = pathinfo($p_image);
    $src = $_FILES['image']['tmp_name'];
    $dest = "../images/$p_image";
    $isMoved = @move_uploaded_file($src, $dest);
	if($isMoved== true){
    $_POST['image'] = $p_image;
	$sql="update pages set image='$p_image' where name='$name'";
    $result=mysql_query($sql)or die(mysql_error());
	
	echo success("Image Changed Successfully");
	}else{
		echo error("File Not Upload");
		}
	}
	if(isset($_POST['bb_development'])){
	$name= $_POST['page'];
    $p_image = $_FILES['image']['name'];
    $p_image = date('ymdHis') . '_' . uniqid() . '_' . $p_image;
    $fileInfoArray = pathinfo($p_image);
    $src = $_FILES['image']['tmp_name'];
    $dest = "../images/$p_image";
    $isMoved = @move_uploaded_file($src, $dest);
	if($isMoved== true){
    $_POST['image'] = $p_image;
	$sql="update pages set image='$p_image' where name='$name'";
    $result=mysql_query($sql)or die(mysql_error());
	
	echo success("Image Changed Successfully");
	}else{
		echo error("File Not Upload");
		}
	}
	if(isset($_POST['ipad_development'])){
	$name= $_POST['page'];
    $p_image = $_FILES['image']['name'];
    $p_image = date('ymdHis') . '_' . uniqid() . '_' . $p_image;
    $fileInfoArray = pathinfo($p_image);
    $src = $_FILES['image']['tmp_name'];
    $dest = "../images/$p_image";
    $isMoved = @move_uploaded_file($src, $dest);
	if($isMoved== true){
    $_POST['image'] = $p_image;
	$sql="update pages set image='$p_image' where name='$name'";
    $result=mysql_query($sql)or die(mysql_error());
	
	echo success("Image Changed Successfully");
	}else{
		echo error("File Not Upload");
		}
	}
	if(isset($_POST['mobile_application'])){
	$name= $_POST['page'];
    $p_image = $_FILES['image']['name'];
    $p_image = date('ymdHis') . '_' . uniqid() . '_' . $p_image;
    $fileInfoArray = pathinfo($p_image);
    $src = $_FILES['image']['tmp_name'];
    $dest = "../images/$p_image";
    $isMoved = @move_uploaded_file($src, $dest);
	if($isMoved== true){
    $_POST['image'] = $p_image;
	$sql="update pages set image='$p_image' where name='$name'";
    $result=mysql_query($sql)or die(mysql_error());
	
	echo success("Image Changed Successfully");
	}else{
		echo error("File Not Upload");
		}
	}
	if(isset($_POST['windows_application'])){
	$name= $_POST['page'];
    $p_image = $_FILES['image']['name'];
    $p_image = date('ymdHis') . '_' . uniqid() . '_' . $p_image;
    $fileInfoArray = pathinfo($p_image);
    $src = $_FILES['image']['tmp_name'];
    $dest = "../images/$p_image";
    $isMoved = @move_uploaded_file($src, $dest);
	if($isMoved== true){
    $_POST['image'] = $p_image;
	$sql="update pages set image='$p_image' where name='$name'";
    $result=mysql_query($sql)or die(mysql_error());
	
	echo success("Image Changed Successfully");
	}else{
		echo error("File Not Upload");
		}
	}
	
	
	
	
	
	if(isset($_GET['msg'])){
		$msg=$_GET['msg'];
		echo success("$msg");
	}?>
	<table class="table table-striped">
		
<?php
$sql=mysql_query("SELECT * FROM pages")or die(mysql_error());
while ($data=mysql_fetch_assoc($sql)) {
?>
			<tr>
				<td colspan="3"><h3 class="title-heading color_yellow"><?=$data['name']?></h3></td>
			</tr>
			<tr>
				<td width="60%">Content</td>
				<td width="35%">Image</td>
				<td width="15%">Edit</td>
			</tr>
			<tr>
				<td><div style="width: 100%; height: 300px; overflow-y: scroll;" id="content"><?=$data['content']?></div></td>
				<td><img src="../images/<?=$data['image']?>" />
					<form action="" method="post" enctype="multipart/form-data">
					<input type="hidden" name="page" value="<?=$data['name']?>" />
					<input class="form-control" type="file" name="image" />
					<input type="submit" value="Change Image" name="<?=$data['name']?>" />	
					</form>
					
				</td>
				<td><a href="editpage.php?name=<?=$data['name']?>" class="edit"><span class="glyphicon glyphicon-edit" style="font-size:30px"></span></a></td>
			</tr>
<?php } ?>			
		</tbody>
	</table>
  </div>

</html>
